<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
</html>
<script !src="">
    // 实现new
    function Test(name) {
        this.name = name
    }

    Test.prototype.sayName = function () {
        console.log(this.name)
    }

    function createMy(Con, ...args) {
        let obj = Object.create(Con.prototype)
//   Object.setPrototypeOf(obj={}, Con.prototype)
        let result = Con.apply(obj, args)
        return result instanceof Object ? result : obj
    }

    let t = createMy(Test, 'ycl')
    console.log(t.name)  // ycl
    t.sayName() // ycl
</script>
